package com.data.construct.queue;

import com.data.construct.array.CycleArray;

/**
 * 用数组实现队列
 * 队列设计头部元素的操作了, 这里要用到自己写的环形数组
 *
 * @author sunhl
 * @Description:
 * @Date: created in 2024/10/28 0028 11:10
 * @Modified By:
 */
public class MyArrayQueue<E> {
    private CycleArray<E> arr;

    public MyArrayQueue() {
        arr = new CycleArray<>();
    }

    public void push(E t) {
        arr.addLast(t);
    }

    public E pop() {
        return arr.removeFirst();
    }

    public E peek() {
        return arr.getFirst();
    }

    public int size() {
        return arr.size();
    }
}
